<?php
declare (strict_types = 1);

namespace app\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'name'     =>  [ 'max' => 30, 'regex' => '/^.{2,15}$/'],
        'nickname' =>  [ 'max' => 50, 'regex' => '/^.{2,25}$/'],
//        'password' =>  ['length'=> '6,16'],
        'mobile'   =>  'mobile',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'name.max'        => '名称最多不能超过30个字符',
        'nickname.max'    => '昵称最多不能超过60个字符',
//        'password.between'=> '密码只能在6-16之间',
        'mobile.require'  => '手机号必须',
        'mobile'          => '手机格式错误',
    ];
}
